/**
 * 
 */
package com.surfilter.code.gen.task;

import javax.swing.JOptionPane;

import org.apache.tools.ant.Task;

import com.surfilter.code.gen.tool.CodeGenTools;
import com.surfilter.dp.context.ContextHolder;

/**
 * Description: 生成Java代码task
 */
public class JavaCodeGenTask extends Task{

    private String dataSource;
    
    private String jsPrefix;
    
    private String jsModPath;
    
    private String pattern;

    private String javaModPath;
    
    private String pkg;
    
    private String isCover;
    
    private String dialet;
    
	public String getIsCover() {
		return isCover;
	}

	public void setIsCover(String isCover) {
		this.isCover = isCover;
	}

	public String getDataSource() {
		return dataSource;
	}

	public void setDataSource(String dataSource) {
		this.dataSource = dataSource;
	}

	public String getJsPrefix() {
		return jsPrefix;
	}

	public void setJsPrefix(String jsPrefix) {
		this.jsPrefix = jsPrefix;
	}

	public String getJsModPath() {
		return jsModPath;
	}

	public void setJsModPath(String jsModPath) {
		this.jsModPath = jsModPath;
	}

	public String getPattern() {
		return pattern;
	}

	public void setPattern(String pattern) {
		this.pattern = pattern;
	}

	public String getJavaModPath() {
		return javaModPath;
	}

	public void setJavaModPath(String javaModPath) {
		this.javaModPath = javaModPath;
	}

	public String getPkg() {
		return pkg;
	}

	public void setPkg(String pkg) {
		this.pkg = pkg;
	}

	/**
	 * @return the dialet
	 */
	public String getDialet() {
		return dialet;
	}

	/**
	 * @param dialet the dialet to set
	 */
	public void setDialet(String dialet) {
		this.dialet = dialet;
	}

	public void execute() {
        	CodeGenTools instance = new CodeGenTools(this.dataSource, this.jsPrefix, this.jsModPath, this.pattern, this.javaModPath, this.pkg, Boolean.parseBoolean(this.isCover),dialet);
        	try {
				instance.genJavaCode(this);
			} catch (Exception e) {
				JOptionPane.showMessageDialog(null, "生成JAVA代码发生错误," + e.getMessage());
				ContextHolder.isGenJavaSuccess = false;
				e.printStackTrace();
			}
    }
}

